<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新增党组织</title>
<link href="/djzx/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/djzx/js/jquery-1.8.1.min.js"></script>
<script language="JavaScript" type="text/javascript" src="/djzx/js/backPage/clientSideApp.js"></script>
<script language="javascript">

function goback(){
	window.location.href="/djzx/OtherPartyAction!getPartyInfoListForPage.action";
}

function saveParty(){
	var name = $.trim($('#name').val());
	var address = $.trim($('#address').val());
	var area = $.trim($('#area').val());
	var type = $.trim($('#type').val());
	var workerNum = $.trim($('#workerNum').val());
	var hasParty = $.trim($('#hasParty').val());
	var partyName = $.trim($('#partyName').val());
	var isRegional = $.trim($('#isRegional').val());
	var memberNum = $.trim($('#memberNum').val());
	var leaderName = $.trim($('#leaderName').val());
	var leaderPolitical = $.trim($('#leaderPolitical').val());
	var leaderTel = $.trim($('#leaderTel').val());
	var note = $.trim($('#note').val());
	
	if(name==""){
		alert("党组织名称不能为空");
		return;
	}
	if(address==""){
		alert("地址不能为空");
		return;
	}
	if(area==""){
		alert("所属片区不能为空");
		return;
	}
	if(type==""){
		alert("单位性质不能为空");
		return;
	}
	if(workerNum==""){
		alert("单位员工数不能为空");
		return;
	}else if(isNaN(workerNum)){
		alert("单位员工数必须为数字");
		return;
	}
	if(hasParty==1){
		if(partyName==""){
			alert("党组织名称不能为空");
			return;
		}
	}else{
		partyName = "";
		isRegional = 0;
	}
	if(memberNum==""){
		alert("党员数不能为空");
		return;
	}else if(isNaN(memberNum)){
		alert("党员数必须为数字");
		return;
	}
	if(leaderName==""){
		alert("负责人姓名不能为空");
		return;
	}
	if(leaderPolitical==""){
		alert("负责人政治面貌不能为空");
		return;
	}
	if(leaderTel==""){
		alert("负责人联系方式不能为空");
		return;
	}
	
	workerNum = parseInt(workerNum);
	memberNum = parseInt(memberNum);
	var fd = new FormData();
	fd.append('otherParty.name',name);
	fd.append('otherParty.address',address);
	fd.append('otherParty.area',area);
	fd.append('otherParty.type',type);
	fd.append('otherParty.workerNum',workerNum);
	fd.append('otherParty.hasParty',hasParty);
	fd.append('otherParty.partyName',partyName);
	fd.append('otherParty.isRegional',isRegional);
	fd.append('otherParty.memberNum',memberNum);
	fd.append('otherParty.leaderName',leaderName);
	fd.append('otherParty.leaderPolitical',leaderPolitical);
	fd.append('otherParty.leaderTel',leaderTel);
	fd.append('otherParty.note',note);
	
	$.ajax({
	    url:"${pageContext.request.contextPath}/OtherPartyAction!savePartyInfo.action",
	    type:"POST",
	    data:fd,
	    dataType: "json", 
	    contentType: false, //必须
	    processData: false, //必须
	    success:function(data){
	    	alert(data.message);
			if(data.success){
				location.href="/djzx/OtherPartyAction!getPartyInfoListForPage.action";
			}
	    }
	}); 
}

function hasPartyCheck(){
	var hasParty = $.trim($('#hasParty').val());
	if(hasParty == ''){
		return;
	}
	if(hasParty == 1){
		$('#partyName').fadeIn();
		$('#isRegional').fadeIn();
		//$('#partyCheck').fadeIn();
	}else{
		$('#partyName').fadeOut();
		$('#isRegional').fadeOut();
		//$('#partyCheck').fadeOut();
	}
}

$(document).ready(function(){
	hasPartyCheck();
});

</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td width="15"><img src="/djzx/images/index_32.gif" width="9" height="9"></td>
        <td valign="bottom" class="title">新增党组织</td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<table align="center" width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="120" height="24" class="td_form01">单位名称</td>
        <td nowrap class=td_form02>
        	<input type="text" name="name" id="name" size="30" />
        </td>
        <td width="120" class="td_form01">地址</td>
        <td nowrap class=td_form02>
        	<input type="text" name="address" id="address" size="30" />
        </td>
      </tr>
      <tr>
      <td height="24" class="td_form01">所属片区</td>
        <td nowrap class=td_form02>
        	<input type="text" name="area" id="area" size="30" />
        </td>
        <td height="24" class="td_form01">单位性质</td>
        <td nowrap class=td_form02>
        	<input type="text" name="type" id="type" size="30" />
        </td>
      </tr>
	  <tr>
	  <td class="td_form01">单位员工数</td>
        <td nowrap class=td_form02>
        	<input type="text" name="workerNum" id="workerNum" size="30" />
        </td>
        <td height="24" class="td_form01">是否建有党组织</td>
        <td nowrap class=td_form02>
        	<select name="hasParty" id="hasParty" onchange="hasPartyCheck()">
              <option value="0">否</option>
			  <option value="1">是</option>
      		</select>
        </td>
      </tr>
      <tr>
	  <td class="td_form01">党组织名称</td>
        <td nowrap class=td_form02>
        	<input type="text" name="partyName" id="partyName" size="30" />
        </td>
        <td height="24" class="td_form01">是否为区域化党建单位</td>
        <td nowrap class=td_form02>
        	<select name="isRegional" id="isRegional">
              <option value="0">否</option>
			  <option value="1">是</option>
      		</select>
        </td>
      </tr>
	  <tr>
	  	<td height="24" class="td_form01">党员数</td>
        <td nowrap class=td_form02>
        	<input type="text" name="memberNum" id="memberNum" size="30" />
        </td>
	  	<td height="24" class="td_form01">负责人姓名</td>
        <td nowrap class=td_form02>
        	<input type="text" name="leaderName" id="leaderName" size="30" />
        </td>
      </tr>
      <tr>
      	<td class="td_form01">负责人电话</td>
        <td nowrap class=td_form02>
        	<input type="text" name="leaderTel" id="leaderTel" size="30" />
        </td>
	  	<td height="24" class="td_form01">负责人政治面貌</td>
        <td nowrap class=td_form02>
        	<input type="text" name="leaderPolitical" id="leaderPolitical" size="30" />
        </td>
      </tr>
      <tr>
		<td height="24" class="td_form01">备注</td>
        <td nowrap class=td_form02 colspan="3">
        	<textarea rows="5" cols="100" id="note" name="note"></textarea>
        </td>
      </tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><input name="Submit2" type="submit" class="buttonface" value="  保存  " onClick="saveParty()">
    <input name="Submit" type="submit" class="buttonface" value="  返回  "  onClick="goback()"></td>
  </tr>
</table>
<br>
</body>
</html>